Skip to content

fix: read qrels corpus-id column without trailing space - #52

Merged
oliverholworthy merged 2 commits into
NVIDIA-NeMo:mainfrom
andrewwhitecdw:andrewwhitecdw/fix/corpus-id-trailing-space
Aug 18, 2026
Merged

fix: read qrels corpus-id column without trailing space#52
oliverholworthy merged 2 commits into
NVIDIA-NeMo:mainfrom
andrewwhitecdw:andrewwhitecdw/fix/corpus-id-trailing-space

Conversation

@andrewwhitecdw

@andrewwhitecdw andrewwhitecdw commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

What

Fix load_positive_docs_with_modality to accept both:

  • corpus-id — the canonical header
  • corpus-id␠ — the legacy header, where represents a trailing space

New files continue to use only the canonical header.

Why

The qrels writer produces corpus-id, but the loader previously expected corpus-id followed by a space. This caused a KeyError when loading normally generated qrels files.

Correcting the lookup alone would break existing files adapted to the old behavior, so the loader now supports both spellings.

How

The loader normalizes the exact legacy header to corpus-id immediately after reading the TSV. The rest of the function consistently uses the canonical name.

Tests cover:

  • Canonical corpus-id
  • Legacy corpus-id␠
  • A document referenced across multiple modalities, where the most frequent modality is selected

Validation

  • Retrieval-SDG tests: 81 passed
  • Ruff lint and formatting checks passed

The qrels TSV is written with header 'corpus-id' (no trailing space), but

load_positive_docs_with_modality looked up row['corpus-id '], which raised

KeyError when the function was used.

Signed-off-by: Andrew White <andrewh@cdw.com>

@shan-nvidia shan-nvidia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The canonical corpus-id fix is correct, but retaining the legacy trailing-space spelling as an input alias avoids an unnecessary compatibility break. I also recommend covering both header variants and the multi-modality resolution path in the regression tests.

Comment thread plugins/data-designer-retrieval-sdg/tests/test_postprocess.py Outdated
Signed-off-by: Oliver Holworthy <1216955+oliverholworthy@users.noreply.github.com>

@oliverholworthy oliverholworthy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this fix. This had been sitting for a few weeks, so I pushed a small follow-up to address the outstanding feedback and unblock it. The update preserves compatibility with the legacy header and extends the regression coverage.

@oliverholworthy
oliverholworthy merged commit b65c6bc into NVIDIA-NeMo:main Aug 18, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants